package edu.tongji.structureplayer.structure
{
    public class Connection extends BaseStructure
    {
        private var _xEnable:Boolean;
        private var _yEnable:Boolean;
        private var _thetaEnable:Boolean;
        private var _func:PiecewiseFunction;
        
        public function Connection(name:String, xEnable:Boolean, yEnable:Boolean, 
                                   thetaEnable:Boolean, func:PiecewiseFunction=null)
        {
            super(name);
            _xEnable = xEnable;
            _yEnable = yEnable;
            _thetaEnable = thetaEnable;
            _func = func;
        }
        
        public function overlap(xEnable:Boolean, yEnable:Boolean, thetaEnable:Boolean, 
                                func:PiecewiseFunction=null):Boolean
        {
            if (xEnable!=_xEnable || yEnable!=_yEnable || thetaEnable!=_thetaEnable
            || _func!=func)
                return false;
            return true;
        }

        public function get xEnable():Boolean
        {
            return _xEnable;
        }

        public function set xEnable(value:Boolean):void
        {
            _xEnable = value;
        }

        public function get yEnable():Boolean
        {
            return _yEnable;
        }

        public function set yEnable(value:Boolean):void
        {
            _yEnable = value;
        }

        public function get thetaEnable():Boolean
        {
            return _thetaEnable;
        }

        public function set thetaEnable(value:Boolean):void
        {
            _thetaEnable = value;
        }

        public function get func():PiecewiseFunction
        {
            return _func;
        }

        public function set func(value:PiecewiseFunction):void
        {
            _func = value;
        }
        
        public function debugPrint():void
        {
            var info:String = "Connection " + name + "(" + _xEnable + ", "
                + _yEnable + ", " + _thetaEnable;
            if (null == _func)
                info += ")";
            else
                info += (", " + _func.name + ")");
            trace(info);
        }

    }
}